<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="root" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>维修信息</title>
<link href="${root}/static/css/bootstrap.min.css" rel="stylesheet"
	type="text/css" />
<script type="text/javascript" src="${root}/static/js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="${root}/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${root}/static/js/vue.min.js"></script>
<script type="text/javascript" src="${root}/static/js/axios.min.js"></script>
<script type="text/javascript"
	src="${root}/static/js/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
	<div id="app" class="container-fluid">
		<div class="col-md-2" style="margin-top: 20px">
			<input type="text" v-model="rrbsno" @keyup="search()"
				placeholder="请输入车牌号关键字" class="form-control" />
		</div>
		<div class="col-md-2" style="margin-top: 20px">
			<button @click="all()"
				class="btn btn-default glyphicon glyphicon-search">所有归还单</button>
		</div>
		<table class="table">
			<caption>维修列表</caption>
			<thead>
				<tr>
					<th>维修单号</th>
					<th>归还单号</th>
					<th>车牌号</th>
					<th>维修项</th>
					<th>维修费用</th>
					<th>维修说明</th>
					<th>维修时间</th>
					<th>维修状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<tr v-for="item in pager.items">
					<td>{{item.rrid}}</td>
					<td>{{item.rrrnid}}</td>
					<td>{{item.rrbsno}}</td>
					<td>{{item.rrproblem}}</td>
					<td>{{item.rrcost}}元</td>
					<td>{{item.rrdesc}}</td>
					<td>{{item.rrtimeS}}</td>
					<td>{{item.rrstatuszh}}</td>
					<td v-if="item.rrstatus == 701"><a @click="repairOk(item)"
						href="javascript:void(0);">
							<button class="btn btn-info">维修完成</button>
					</a></td>
					<td v-else><a href="javascript:void(0);">
							<button class="btn btn-info" disabled="disabled">已完成</button>
					</a></td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="10">
						<ul class="pagination">
							<li><a href="javascript:void(0);" @click="list(1)">&laquo;</a></li>
							<li><a href="javascript:void(0);"
								@click="list(pager.begin-pager.step)">&larr;</a></li>
						</ul>
						<ul class="pagination" v-for="n in pager.end+1-pager.begin">
							<li :class="pager.begin+n-1==pager.index?'active':''"><a
								href="javascript:void(0);" @click="list(pager.begin+n-1)">{{pager.begin+n-1}}</a>
							</li>
						</ul>
						<ul class="pagination">
							<li><a href="javascript:void(0);"
								@click="list(pager.begin+pager.step)">&rarr;</a></li>
							<li><a href="javascript:void(0);" @click="list(pager.page)">&raquo;</a></li>
						</ul>
					</td>
				</tr>
			</tfoot>
		</table>
	</div>
	<script type="text/javascript">
		new Vue({
			el : '#app',
			data : {
				index : 1,
				size : 5,
				step : 10,
				rrbsno : "",
				pager : {},
			},
			methods : {
				list : function(index) {
					var self = this;
					self.index = index;
					var url = "${root}/repair/list?rrbsno=" + self.rrbsno
							+ "&index=" + self.index + "&size=" + self.size
							+ "&step=" + self.step;
					axios.get(url).then(function(res) {
						self.pager = res.data;
					});
				},
				search : function() {
					var self = this;
					self.index = 1;
					self.list(self.index);
				},
				all : function() {
					var self = this;
					self.rrbsno = "";
					self.index = 1;
					self.list(self.index);
				},
				repairOk : function(item) {
					var self = this;
					var url = "${root}/repair/ok?rrid=" + item.rrid
							+ "&rrbsno=" + item.rrbsno;
					axios.get(url).then(function(res) {
						alert(res.data.message);
						self.list(self.index);
					});
				}
			},
			mounted : function() {
				this.list(this.index);
			}
		})
	</script>
</body>
</html>